<script lang="ts" setup>
import { useConsole, useRouteGuard } from '@/utils'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { object as zobject, string as zstring } from 'zod'

const src = ref('')

onLoad(async (query: any) => {
  useConsole?.log('query', query)
  const zparse = zobject({
    src: zstring()
      .transform(decodeURIComponent),
    // .refine(x => zstring().regex(/^https?:\/\/.+$/).safeParse(x).success),
  }).safeParse(query)
  if (!zparse.success) {
    return await useRouteGuard()
  }
  useConsole?.log('zparse.data', zparse.data)
  src.value = zparse.data.src
})
</script>

<template>
  <web-view :src="src"></web-view>
</template>

<style lang="less" scoped></style>
